home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 4 / Macwelt DVD 4.cdr / Entwickler / Mac-OS / oxygen / samples / docbook / xsl / html / inline.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2002-09-09  |  30.9 KB  |  988 lines  |  [□□□□/□□□□]

  1. inline.xslyπ¢tÚπ¢tÚÅź4<?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3.                 xmlns:xlink='http://www.w3.org/1999/xlink'
  4.                 exclude-result-prefixes="xlink"
  5.                 version='1.0'>
  6.  
  7. <!-- ********************************************************************
  8.      $Id: inline.xsl,v 1.1 2002/05/29 09:55:49 dan Exp $
  9.      ********************************************************************
  10.  
  11.      This file is part of the XSL DocBook Stylesheet distribution.
  12.      See ../README or http://nwalsh.com/docbook/xsl/ for copyright
  13.      and other information.
  14.  
  15.      ******************************************************************** -->
  16.  
  17. <xsl:template name="simple.xlink">
  18.   <xsl:param name="node" select="."/>
  19.   <xsl:param name="content">
  20.     <xsl:apply-templates/>
  21.   </xsl:param>
  22.  
  23.   <xsl:choose>
  24.     <xsl:when test="$node/@xlink:type='simple' and $node/@xlink:href">
  25.       <a>
  26.         <xsl:if test="@xlink.title">
  27.           <xsl:attribute name="title">
  28.             <xsl:value-of select="@xlink:title"/>
  29.           </xsl:attribute>
  30.         </xsl:if>
  31.  
  32.         <xsl:attribute name="href">
  33.           <xsl:choose>
  34.             <!-- if the href starts with # and does not contain an "(" -->
  35.             <!-- or if the href starts with #xpointer(id(, it's just an ID -->
  36.             <xsl:when test="starts-with(@xlink:href,'#')
  37.                             and (not(contains(@xlink:href,'('))
  38.                             or starts-with(@xlink:href,'#xpointer(id('))">
  39.               <xsl:variable name="idref">
  40.                 <xsl:call-template name="xpointer.idref">
  41.                   <xsl:with-param name="xpointer" select="@xlink:href"/>
  42.                 </xsl:call-template>
  43.               </xsl:variable>
  44.  
  45.               <xsl:variable name="targets" select="key('id',$idref)"/>
  46.               <xsl:variable name="target" select="$targets[1]"/>
  47.  
  48.               <xsl:call-template name="check.id.unique">
  49.                 <xsl:with-param name="linkend" select="@linkend"/>
  50.               </xsl:call-template>
  51.  
  52.               <xsl:choose>
  53.                 <xsl:when test="count($target) = 0">
  54.                   <xsl:message>
  55.                     <xsl:text>XLink to nonexistent id: </xsl:text>
  56.                     <xsl:value-of select="$idref"/>
  57.                   </xsl:message>
  58.                   <xsl:text>???</xsl:text>
  59.                 </xsl:when>
  60.                 <xsl:otherwise>
  61.                   <xsl:call-template name="href.target">
  62.                     <xsl:with-param name="object" select="$target"/>
  63.                   </xsl:call-template>
  64.                 </xsl:otherwise>
  65.               </xsl:choose>
  66.             </xsl:when>
  67.  
  68.             <!-- otherwise it's a URI -->
  69.             <xsl:otherwise>
  70.               <xsl:value-of select="@xlink:href"/>
  71.             </xsl:otherwise>
  72.           </xsl:choose>
  73.         </xsl:attribute>
  74.         <xsl:copy-of select="$content"/>
  75.       </a>
  76.     </xsl:when>
  77.     <xsl:otherwise>
  78.       <xsl:copy-of select="$content"/>
  79.     </xsl:otherwise>
  80.   </xsl:choose>
  81. </xsl:template>
  82.  
  83. <xsl:template name="inline.charseq">
  84.   <xsl:param name="content">
  85.     <xsl:call-template name="anchor"/>
  86.     <xsl:call-template name="simple.xlink">
  87.       <xsl:with-param name="content">
  88.         <xsl:apply-templates/>
  89.       </xsl:with-param>
  90.     </xsl:call-template>
  91.   </xsl:param>
  92.   <xsl:copy-of select="$content"/>
  93. </xsl:template>
  94.  
  95. <xsl:template name="inline.monoseq">
  96.   <xsl:param name="content">
  97.     <xsl:call-template name="anchor"/>
  98.     <xsl:call-template name="simple.xlink">
  99.       <xsl:with-param name="content">
  100.         <xsl:apply-templates/>
  101.       </xsl:with-param>
  102.     </xsl:call-template>
  103.   </xsl:param>
  104.   <tt><xsl:copy-of select="$content"/></tt>
  105. </xsl:template>
  106.  
  107. <xsl:template name="inline.boldseq">
  108.   <xsl:param name="content">
  109.     <xsl:call-template name="anchor"/>
  110.     <xsl:call-template name="simple.xlink">
  111.       <xsl:with-param name="content">
  112.         <xsl:apply-templates/>
  113.       </xsl:with-param>
  114.     </xsl:call-template>
  115.   </xsl:param>
  116.   <!-- don't put <b> inside figure, example, or table titles -->
  117.   <xsl:choose>
  118.     <xsl:when test="local-name(..) = 'title'
  119.                     and (local-name(../..) = 'figure'
  120.                          or local-name(../..) = 'example'
  121.                          or local-name(../..) = 'table')">
  122.       <xsl:copy-of select="$content"/>
  123.     </xsl:when>
  124.     <xsl:otherwise>
  125.       <b><xsl:copy-of select="$content"/></b>
  126.     </xsl:otherwise>
  127.   </xsl:choose>
  128. </xsl:template>
  129.  
  130. <xsl:template name="inline.italicseq">
  131.   <xsl:param name="content">
  132.     <xsl:call-template name="anchor"/>
  133.     <xsl:call-template name="simple.xlink">
  134.       <xsl:with-param name="content">
  135.         <xsl:apply-templates/>
  136.       </xsl:with-param>
  137.     </xsl:call-template>
  138.   </xsl:param>
  139.   <i><xsl:copy-of select="$content"/></i>
  140. </xsl:template>
  141.  
  142. <xsl:template name="inline.boldmonoseq">
  143.   <xsl:param name="content">
  144.     <xsl:call-template name="anchor"/>
  145.     <xsl:call-template name="simple.xlink">
  146.       <xsl:with-param name="content">
  147.         <xsl:apply-templates/>
  148.       </xsl:with-param>
  149.     </xsl:call-template>
  150.   </xsl:param>
  151.   <!-- don't put <b> inside figure, example, or table titles -->
  152.   <!-- or other titles that may already be represented with <b>'s. -->
  153.   <xsl:choose>
  154.     <xsl:when test="local-name(..) = 'title'
  155.                     and (local-name(../..) = 'figure'
  156.                          or local-name(../..) = 'example'
  157.                          or local-name(../..) = 'table'
  158.                          or local-name(../..) = 'formalpara')">
  159.       <tt><xsl:copy-of select="$content"/></tt>
  160.     </xsl:when>
  161.     <xsl:otherwise>
  162.       <b><tt><xsl:copy-of select="$content"/></tt></b>
  163.     </xsl:otherwise>
  164.   </xsl:choose>
  165. </xsl:template>
  166.  
  167. <xsl:template name="inline.italicmonoseq">
  168.   <xsl:param name="content">
  169.     <xsl:call-template name="anchor"/>
  170.     <xsl:call-template name="simple.xlink">
  171.       <xsl:with-param name="content">
  172.         <xsl:apply-templates/>
  173.       </xsl:with-param>
  174.     </xsl:call-template>
  175.   </xsl:param>
  176.   <i><tt><xsl:copy-of select="$content"/></tt></i>
  177. </xsl:template>
  178.  
  179. <xsl:template name="inline.superscriptseq">
  180.   <xsl:param name="content">
  181.     <xsl:call-template name="anchor"/>
  182.     <xsl:call-template name="simple.xlink">
  183.       <xsl:with-param name="content">
  184.         <xsl:apply-templates/>
  185.       </xsl:with-param>
  186.     </xsl:call-template>
  187.   </xsl:param>
  188.   <sup><xsl:copy-of select="$content"/></sup>
  189. </xsl:template>
  190.  
  191. <xsl:template name="inline.subscriptseq">
  192.   <xsl:param name="content">
  193.     <xsl:call-template name="anchor"/>
  194.     <xsl:call-template name="simple.xlink">
  195.       <xsl:with-param name="content">
  196.         <xsl:apply-templates/>
  197.       </xsl:with-param>
  198.     </xsl:call-template>
  199.   </xsl:param>
  200.   <sub><xsl:copy-of select="$content"/></sub>
  201. </xsl:template>
  202.  
  203. <!-- ==================================================================== -->
  204. <!-- some special cases -->
  205.  
  206. <xsl:template match="author">
  207.   <span class="{name(.)}"><xsl:call-template name="person.name"/></span>
  208. </xsl:template>
  209.  
  210. <xsl:template match="editor">
  211.   <span class="{name(.)}"><xsl:call-template name="person.name"/></span>
  212. </xsl:template>
  213.  
  214. <xsl:template match="othercredit">
  215.   <span class="{name(.)}"><xsl:call-template name="person.name"/></span>
  216. </xsl:template>
  217.  
  218. <xsl:template match="authorinitials">
  219.   <xsl:call-template name="inline.charseq"/>
  220. </xsl:template>
  221.  
  222. <!-- ==================================================================== -->
  223.  
  224. <xsl:template match="accel">
  225.   <xsl:call-template name="inline.charseq"/>
  226. </xsl:template>
  227.  
  228. <xsl:template match="action">
  229.   <xsl:call-template name="inline.charseq"/>
  230. </xsl:template>
  231.  
  232. <xsl:template match="application">
  233.   <xsl:call-template name="inline.charseq"/>
  234. </xsl:template>
  235.  
  236. <xsl:template match="classname">
  237.   <xsl:call-template name="inline.monoseq"/>
  238. </xsl:template>
  239.  
  240. <xsl:template match="exceptionname">
  241.   <xsl:call-template name="inline.monoseq"/>
  242. </xsl:template>
  243.  
  244. <xsl:template match="interfacename">
  245.   <xsl:call-template name="inline.monoseq"/>
  246. </xsl:template>
  247.  
  248. <xsl:template match="methodname">
  249.   <xsl:call-template name="inline.monoseq"/>
  250. </xsl:template>
  251.  
  252. <xsl:template match="command">
  253.   <xsl:call-template name="inline.boldseq"/>
  254. </xsl:template>
  255.  
  256. <xsl:template match="computeroutput">
  257.   <xsl:call-template name="inline.monoseq"/>
  258. </xsl:template>
  259.  
  260. <xsl:template match="constant">
  261.   <xsl:call-template name="inline.monoseq"/>
  262. </xsl:template>
  263.  
  264. <xsl:template match="database">
  265.   <xsl:call-template name="inline.charseq"/>
  266. </xsl:template>
  267.  
  268. <xsl:template match="errorcode">
  269.   <xsl:call-template name="inline.charseq"/>
  270. </xsl:template>
  271.  
  272. <xsl:template match="errorname">
  273.   <xsl:call-template name="inline.charseq"/>
  274. </xsl:template>
  275.  
  276. <xsl:template match="errortype">
  277.   <xsl:call-template name="inline.charseq"/>
  278. </xsl:template>
  279.  
  280. <xsl:template match="envar">
  281.   <xsl:call-template name="inline.monoseq"/>
  282. </xsl:template>
  283.  
  284. <xsl:template match="filename">
  285.   <xsl:call-template name="inline.monoseq"/>
  286. </xsl:template>
  287.  
  288. <xsl:template match="function">
  289.   <xsl:choose>
  290.     <xsl:when test="$function.parens != '0'
  291.                     and (parameter or function or replaceable)">
  292.       <xsl:variable name="nodes" select="text()|*"/>
  293.       <xsl:call-template name="inline.monoseq">
  294.         <xsl:with-param name="content">
  295.           <xsl:call-template name="simple.xlink">
  296.             <xsl:with-param name="content">
  297.               <xsl:apply-templates select="$nodes[1]"/>
  298.             </xsl:with-param>
  299.           </xsl:call-template>
  300.         </xsl:with-param>
  301.       </xsl:call-template>
  302.       <xsl:text>(</xsl:text>
  303.       <xsl:apply-templates select="$nodes[position()>1]"/>
  304.       <xsl:text>)</xsl:text>
  305.     </xsl:when>
  306.     <xsl:otherwise>
  307.      <xsl:call-template name="inline.monoseq"/>
  308.     </xsl:otherwise>
  309.   </xsl:choose>
  310. </xsl:template>
  311.  
  312. <xsl:template match="function/parameter" priority="2">
  313.   <xsl:call-template name="inline.italicmonoseq"/>
  314.   <xsl:if test="following-sibling::*">
  315.     <xsl:text>, </xsl:text>
  316.   </xsl:if>
  317. </xsl:template>
  318.  
  319. <xsl:template match="function/replaceable" priority="2">
  320.   <xsl:call-template name="inline.italicmonoseq"/>
  321.   <xsl:if test="following-sibling::*">
  322.     <xsl:text>, </xsl:text>
  323.   </xsl:if>
  324. </xsl:template>
  325.  
  326. <xsl:template match="guibutton">
  327.   <xsl:call-template name="inline.charseq"/>
  328. </xsl:template>
  329.  
  330. <xsl:template match="guiicon">
  331.   <xsl:call-template name="inline.charseq"/>
  332. </xsl:template>
  333.  
  334. <xsl:template match="guilabel">
  335.   <xsl:call-template name="inline.charseq"/>
  336. </xsl:template>
  337.  
  338. <xsl:template match="guimenu">
  339.   <xsl:call-template name="inline.charseq"/>
  340. </xsl:template>
  341.  
  342. <xsl:template match="guimenuitem">
  343.   <xsl:call-template name="inline.charseq"/>
  344. </xsl:template>
  345.  
  346. <xsl:template match="guisubmenu">
  347.   <xsl:call-template name="inline.charseq"/>
  348. </xsl:template>
  349.  
  350. <xsl:template match="hardware">
  351.   <xsl:call-template name="inline.charseq"/>
  352. </xsl:template>
  353.  
  354. <xsl:template match="interface">
  355.   <xsl:call-template name="inline.charseq"/>
  356. </xsl:template>
  357.  
  358. <xsl:template match="interfacedefinition">
  359.   <xsl:call-template name="inline.charseq"/>
  360. </xsl:template>
  361.  
  362. <xsl:template match="keycap">
  363.   <xsl:call-template name="inline.boldseq"/>
  364. </xsl:template>
  365.  
  366. <xsl:template match="keycode">
  367.   <xsl:call-template name="inline.charseq"/>
  368. </xsl:template>
  369.  
  370. <xsl:template match="keysym">
  371.   <xsl:call-template name="inline.charseq"/>
  372. </xsl:template>
  373.  
  374. <xsl:template match="literal">
  375.   <xsl:call-template name="inline.monoseq"/>
  376. </xsl:template>
  377.  
  378. <xsl:template match="medialabel">
  379.   <xsl:call-template name="inline.italicseq"/>
  380. </xsl:template>
  381.  
  382. <xsl:template match="shortcut">
  383.   <xsl:call-template name="inline.boldseq"/>
  384. </xsl:template>
  385.  
  386. <xsl:template match="mousebutton">
  387.   <xsl:call-template name="inline.charseq"/>
  388. </xsl:template>
  389.  
  390. <xsl:template match="option">
  391.   <xsl:call-template name="inline.monoseq"/>
  392. </xsl:template>
  393.  
  394. <xsl:template match="parameter">
  395.   <xsl:call-template name="inline.italicmonoseq"/>
  396. </xsl:template>
  397.  
  398. <xsl:template match="property">
  399.   <xsl:call-template name="inline.charseq"/>
  400. </xsl:template>
  401.  
  402. <xsl:template match="prompt">
  403.   <xsl:call-template name="inline.monoseq"/>
  404. </xsl:template>
  405.  
  406. <xsl:template match="replaceable" priority="1">
  407.   <xsl:call-template name="inline.italicmonoseq"/>
  408. </xsl:template>
  409.  
  410. <xsl:template match="returnvalue">
  411.   <xsl:call-template name="inline.charseq"/>
  412. </xsl:template>
  413.  
  414. <xsl:template match="structfield">
  415.   <xsl:call-template name="inline.italicmonoseq"/>
  416. </xsl:template>
  417.  
  418. <xsl:template match="structname">
  419.   <xsl:call-template name="inline.charseq"/>
  420. </xsl:template>
  421.  
  422. <xsl:template match="symbol">
  423.   <xsl:call-template name="inline.charseq"/>
  424. </xsl:template>
  425.  
  426. <xsl:template match="systemitem">
  427.   <xsl:call-template name="inline.monoseq"/>
  428. </xsl:template>
  429.  
  430. <xsl:template match="token">
  431.   <xsl:call-template name="inline.charseq"/>
  432. </xsl:template>
  433.  
  434. <xsl:template match="type">
  435.   <xsl:call-template name="inline.charseq"/>
  436. </xsl:template>
  437.  
  438. <xsl:template match="userinput">
  439.   <xsl:call-template name="inline.boldmonoseq"/>
  440. </xsl:template>
  441.  
  442. <xsl:template match="abbrev">
  443.   <xsl:call-template name="inline.charseq"/>
  444. </xsl:template>
  445.  
  446. <xsl:template match="acronym">
  447.   <xsl:call-template name="inline.charseq"/>
  448. </xsl:template>
  449.  
  450. <xsl:template match="citerefentry">
  451.   <xsl:choose>
  452.     <xsl:when test="$citerefentry.link != '0'">
  453.       <a>
  454.         <xsl:attribute name="href">
  455.           <xsl:call-template name="generate.citerefentry.link"/>
  456.         </xsl:attribute>
  457.         <xsl:call-template name="inline.charseq"/>
  458.       </a>
  459.     </xsl:when>
  460.     <xsl:otherwise>
  461.       <xsl:call-template name="inline.charseq"/>
  462.     </xsl:otherwise>
  463.   </xsl:choose>
  464. </xsl:template>
  465.  
  466. <xsl:template name="generate.citerefentry.link">
  467.   <!-- nop -->
  468. </xsl:template>
  469.  
  470. <xsl:template name="x.generate.citerefentry.link">
  471.   <xsl:text>http://example.com/cgi-bin/man.cgi?</xsl:text>
  472.   <xsl:value-of select="refentrytitle"/>
  473.   <xsl:text>(</xsl:text>
  474.   <xsl:value-of select="manvolnum"/>
  475.   <xsl:text>)</xsl:text>
  476. </xsl:template>
  477.  
  478. <xsl:template match="citetitle">
  479.   <xsl:choose>
  480.     <xsl:when test="@pubwork = 'article'">
  481.       <xsl:call-template name="gentext.startquote"/>
  482.       <xsl:call-template name="inline.charseq"/>
  483.       <xsl:call-template name="gentext.endquote"/>
  484.     </xsl:when>
  485.     <xsl:otherwise>
  486.       <xsl:call-template name="inline.italicseq"/>
  487.     </xsl:otherwise>
  488.   </xsl:choose>
  489. </xsl:template>
  490.  
  491. <xsl:template match="emphasis">
  492.   <span>
  493.     <xsl:choose>
  494.       <xsl:when test="@role and $emphasis.propagates.style != 0">
  495.         <xsl:attribute name="class">
  496.           <xsl:value-of select="@role"/>
  497.         </xsl:attribute>
  498.       </xsl:when>
  499.       <xsl:otherwise>
  500.         <xsl:attribute name="class">
  501.           <xsl:text>emphasis</xsl:text>
  502.         </xsl:attribute>
  503.       </xsl:otherwise>
  504.     </xsl:choose>
  505.     <xsl:call-template name="anchor"/>
  506.  
  507.     <xsl:call-template name="simple.xlink">
  508.       <xsl:with-param name="content">
  509.         <xsl:choose>
  510.           <xsl:when test="@role = 'bold'">
  511.             <!-- backwards compatibility: make bold into b elements, but -->
  512.             <!-- don't put bold inside figure, example, or table titles -->
  513.             <xsl:choose>
  514.               <xsl:when test="local-name(..) = 'title'
  515.                               and (local-name(../..) = 'figure'
  516.                               or local-name(../..) = 'example'
  517.                               or local-name(../..) = 'table')">
  518.                 <xsl:apply-templates/>
  519.               </xsl:when>
  520.               <xsl:otherwise>
  521.                 <b><xsl:apply-templates/></b>
  522.               </xsl:otherwise>
  523.             </xsl:choose>
  524.           </xsl:when>
  525.           <xsl:otherwise>
  526.             <em><xsl:apply-templates/></em>
  527.           </xsl:otherwise>
  528.         </xsl:choose>
  529.       </xsl:with-param>
  530.     </xsl:call-template>
  531.   </span>
  532. </xsl:template>
  533.  
  534. <xsl:template match="foreignphrase">
  535.   <xsl:call-template name="inline.italicseq"/>
  536. </xsl:template>
  537.  
  538. <xsl:template match="markup">
  539.   <xsl:call-template name="inline.charseq"/>
  540. </xsl:template>
  541.  
  542. <xsl:template match="phrase">
  543.   <span>
  544.     <xsl:if test="@role and $phrase.propagates.style != 0">
  545.       <xsl:attribute name="class">
  546.         <xsl:value-of select="@role"/>
  547.       </xsl:attribute>
  548.     </xsl:if>
  549.     <xsl:call-template name="anchor"/>
  550.     <xsl:call-template name="simple.xlink">
  551.       <xsl:with-param name="content">
  552.         <xsl:apply-templates/>
  553.       </xsl:with-param>
  554.     </xsl:call-template>
  555.   </span>
  556. </xsl:template>
  557.  
  558. <xsl:template match="quote">
  559.   <xsl:variable name="depth">
  560.     <xsl:call-template name="dot.count">
  561.       <xsl:with-param name="string"><xsl:number level="multiple"/></xsl:with-param>
  562.     </xsl:call-template>
  563.   </xsl:variable>
  564.   <xsl:choose>
  565.     <xsl:when test="$depth mod 2 = 0">
  566.       <xsl:call-template name="gentext.startquote"/>
  567.       <xsl:call-template name="inline.charseq"/>
  568.       <xsl:call-template name="gentext.endquote"/>
  569.     </xsl:when>
  570.     <xsl:otherwise>
  571.       <xsl:call-template name="gentext.nestedstartquote"/>
  572.       <xsl:call-template name="inline.charseq"/>
  573.       <xsl:call-template name="gentext.nestedendquote"/>
  574.     </xsl:otherwise>
  575.   </xsl:choose>
  576. </xsl:template>
  577.  
  578. <xsl:template match="varname">
  579.   <xsl:call-template name="inline.monoseq"/>
  580. </xsl:template>
  581.  
  582. <xsl:template match="wordasword">
  583.   <xsl:call-template name="inline.italicseq"/>
  584. </xsl:template>
  585.  
  586. <xsl:template match="lineannotation">
  587.   <xsl:call-template name="inline.charseq"/>
  588. </xsl:template>
  589.  
  590. <xsl:template match="superscript">
  591.   <xsl:call-template name="inline.superscriptseq"/>
  592. </xsl:template>
  593.  
  594. <xsl:template match="subscript">
  595.   <xsl:call-template name="inline.subscriptseq"/>
  596. </xsl:template>
  597.  
  598. <xsl:template match="trademark">
  599.   <xsl:call-template name="inline.charseq"/>
  600.   <xsl:choose>
  601.     <xsl:when test="@class = 'copyright'
  602.                     or @class = 'registered'">
  603.       <xsl:call-template name="dingbat">
  604.         <xsl:with-param name="dingbat" select="@class"/>
  605.       </xsl:call-template>
  606.     </xsl:when>
  607.     <xsl:when test="@class = 'service'">
  608.       <sup>SM</sup>
  609.     </xsl:when>
  610.     <xsl:otherwise>
  611.       <xsl:call-template name="dingbat">
  612.         <xsl:with-param name="dingbat" select="'trademark'"/>
  613.       </xsl:call-template>
  614.     </xsl:otherwise>
  615.   </xsl:choose>
  616. </xsl:template>
  617.  
  618. <xsl:template match="firstterm">
  619.   <xsl:call-template name="glossterm">
  620.     <xsl:with-param name="firstterm" select="1"/>
  621.   </xsl:call-template>
  622. </xsl:template>
  623.  
  624. <xsl:template match="glossterm" name="glossterm">
  625.   <xsl:param name="firstterm" select="0"/>
  626.  
  627.   <xsl:choose>
  628.  
  629.     <xsl:when test="($firstterm.only.link = 0 or $firstterm = 1) and @linkend">
  630.       <xsl:variable name="targets" select="key('id',@linkend)"/>
  631.       <xsl:variable name="target" select="$targets[1]"/>
  632.  
  633.       <xsl:call-template name="check.id.unique">
  634.         <xsl:with-param name="linkend" select="@linkend"/>
  635.       </xsl:call-template>
  636.  
  637.       <a>
  638.         <xsl:if test="@id">
  639.           <xsl:attribute name="name">
  640.             <xsl:value-of select="@id"/>
  641.           </xsl:attribute>
  642.         </xsl:if>
  643.  
  644.         <xsl:attribute name="href">
  645.           <xsl:call-template name="href.target">
  646.             <xsl:with-param name="object" select="$target"/>
  647.           </xsl:call-template>
  648.         </xsl:attribute>
  649.  
  650.         <xsl:call-template name="inline.italicseq"/>
  651.       </a>
  652.     </xsl:when>
  653.  
  654.     <xsl:when test="not(@linkend)
  655.                     and ($firstterm.only.link = 0 or $firstterm = 1)
  656.                     and $glossary.collection != ''">
  657.       <xsl:variable name="term">
  658.         <xsl:choose>
  659.           <xsl:when test="@baseform"><xsl:value-of select="@baseform"/></xsl:when>
  660.           <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
  661.         </xsl:choose>
  662.       </xsl:variable>
  663.  
  664.       <xsl:variable name="cterm"
  665.            select="(document($glossary.collection,.)//glossentry[glossterm=$term])[1]"/>
  666.  
  667.       <!-- HACK HACK HACK! But it works... -->
  668.       <!-- You'd need to do more work if you wanted to chunk on glossdiv, though -->
  669.  
  670.       <xsl:variable name="glossary" select="//glossary[@role='auto']"/>
  671.  
  672.       <xsl:if test="count($glossary) != 1">
  673.         <xsl:message>
  674.           <xsl:text>Warning: glossary.collection specified, but there are </xsl:text>
  675.           <xsl:value-of select="count($glossary)"/>
  676.           <xsl:text> automatic glossaries</xsl:text>
  677.         </xsl:message>
  678.       </xsl:if>
  679.  
  680.       <xsl:variable name="glosschunk">
  681.         <xsl:call-template name="href.target">
  682.           <xsl:with-param name="object" select="$glossary"/>
  683.         </xsl:call-template>
  684.       </xsl:variable>
  685.  
  686.       <xsl:variable name="chunkbase">
  687.         <xsl:choose>
  688.           <xsl:when test="contains($glosschunk, '#')">
  689.             <xsl:value-of select="substring-before($glosschunk, '#')"/>
  690.           </xsl:when>
  691.           <xsl:otherwise>
  692.             <xsl:value-of select="$glosschunk"/>
  693.           </xsl:otherwise>
  694.         </xsl:choose>
  695.       </xsl:variable>
  696.  
  697.       <xsl:choose>
  698.         <xsl:when test="not($cterm)">
  699.           <xsl:message>
  700.             <xsl:text>There's no entry for </xsl:text>
  701.             <xsl:value-of select="$term"/>
  702.             <xsl:text> in </xsl:text>
  703.             <xsl:value-of select="$glossary.collection"/>
  704.           </xsl:message>
  705.           <xsl:call-template name="inline.italicseq"/>
  706.         </xsl:when>
  707.         <xsl:otherwise>
  708.           <xsl:variable name="id">
  709.             <xsl:text>gl.</xsl:text>
  710.             <xsl:choose>
  711.               <xsl:when test="$cterm/@id">
  712.                 <xsl:value-of select="$cterm/@id"/>
  713.               </xsl:when>
  714.               <xsl:otherwise>
  715.                 <xsl:value-of select="generate-id($cterm)"/>
  716.               </xsl:otherwise>
  717.             </xsl:choose>
  718.           </xsl:variable>
  719.           <a href="{$chunkbase}#{$id}">
  720.             <xsl:call-template name="inline.italicseq"/>
  721.           </a>
  722.         </xsl:otherwise>
  723.       </xsl:choose>
  724.     </xsl:when>
  725.  
  726.     <xsl:when test="not(@linkend)
  727.                     and ($firstterm.only.link = 0 or $firstterm = 1)
  728.                     and $glossterm.auto.link != 0">
  729.       <xsl:variable name="term">
  730.         <xsl:choose>
  731.           <xsl:when test="@baseform">
  732.             <xsl:value-of select="@baseform"/>
  733.           </xsl:when>
  734.           <xsl:otherwise>
  735.             <xsl:value-of select="."/>
  736.           </xsl:otherwise>
  737.         </xsl:choose>
  738.       </xsl:variable>
  739.       <xsl:variable name="targets"
  740.                     select="//glossentry[glossterm=$term or glossterm/@baseform=$term]"/>
  741.       <xsl:variable name="target" select="$targets[1]"/>
  742.  
  743.       <xsl:choose>
  744.         <xsl:when test="count($targets)=0">
  745.           <xsl:message>
  746.             <xsl:text>Error: no glossentry for glossterm: </xsl:text>
  747.             <xsl:value-of select="."/>
  748.             <xsl:text>.</xsl:text>
  749.           </xsl:message>
  750.           <xsl:call-template name="inline.italicseq"/>
  751.         </xsl:when>
  752.         <xsl:otherwise>
  753.           <a>
  754.             <xsl:if test="@id">
  755.               <xsl:attribute name="name">
  756.                 <xsl:value-of select="@id"/>
  757.               </xsl:attribute>
  758.             </xsl:if>
  759.  
  760.             <xsl:attribute name="href">
  761.               <xsl:call-template name="href.target">
  762.                 <xsl:with-param name="object" select="$target"/>
  763.               </xsl:call-template>
  764.             </xsl:attribute>
  765.  
  766.             <xsl:call-template name="inline.italicseq"/>
  767.           </a>
  768.         </xsl:otherwise>
  769.       </xsl:choose>
  770.     </xsl:when>
  771.  
  772.     <xsl:otherwise>
  773.       <xsl:call-template name="inline.italicseq"/>
  774.     </xsl:otherwise>
  775.   </xsl:choose>
  776. </xsl:template>
  777.  
  778. <xsl:template match="sgmltag">
  779.   <xsl:call-template name="format.sgmltag"/>
  780. </xsl:template>
  781.  
  782. <xsl:template name="format.sgmltag">
  783.   <xsl:param name="class">
  784.     <xsl:choose>
  785.       <xsl:when test="@class">
  786.         <xsl:value-of select="@class"/>
  787.       </xsl:when>
  788.       <xsl:otherwise>element</xsl:otherwise>
  789.     </xsl:choose>
  790.   </xsl:param>
  791.  
  792.   <tt class="sgmltag-{$class}">
  793.     <xsl:choose>
  794.       <xsl:when test="$class='attribute'">
  795.         <xsl:apply-templates/>
  796.       </xsl:when>
  797.       <xsl:when test="$class='attvalue'">
  798.         <xsl:apply-templates/>
  799.       </xsl:when>
  800.       <xsl:when test="$class='element'">
  801.         <xsl:apply-templates/>
  802.       </xsl:when>
  803.       <xsl:when test="$class='endtag'">
  804.         <xsl:text></</xsl:text>
  805.         <xsl:apply-templates/>
  806.         <xsl:text>></xsl:text>
  807.       </xsl:when>
  808.       <xsl:when test="$class='genentity'">
  809.         <xsl:text>&</xsl:text>
  810.         <xsl:apply-templates/>
  811.         <xsl:text>;</xsl:text>
  812.       </xsl:when>
  813.       <xsl:when test="$class='numcharref'">
  814.         <xsl:text>&#</xsl:text>
  815.         <xsl:apply-templates/>
  816.         <xsl:text>;</xsl:text>
  817.       </xsl:when>
  818.       <xsl:when test="$class='paramentity'">
  819.         <xsl:text>%</xsl:text>
  820.         <xsl:apply-templates/>
  821.         <xsl:text>;</xsl:text>
  822.       </xsl:when>
  823.       <xsl:when test="$class='pi'">
  824.         <xsl:text><?</xsl:text>
  825.         <xsl:apply-templates/>
  826.         <xsl:text>></xsl:text>
  827.       </xsl:when>
  828.       <xsl:when test="$class='xmlpi'">
  829.         <xsl:text><?</xsl:text>
  830.         <xsl:apply-templates/>
  831.         <xsl:text>?></xsl:text>
  832.       </xsl:when>
  833.       <xsl:when test="$class='starttag'">
  834.         <xsl:text><</xsl:text>
  835.         <xsl:apply-templates/>
  836.         <xsl:text>></xsl:text>
  837.       </xsl:when>
  838.       <xsl:when test="$class='emptytag'">
  839.         <xsl:text><</xsl:text>
  840.         <xsl:apply-templates/>
  841.         <xsl:text>/></xsl:text>
  842.       </xsl:when>
  843.       <xsl:when test="$class='sgmlcomment'">
  844.         <xsl:text><!--</xsl:text>
  845.         <xsl:apply-templates/>
  846.         <xsl:text>--></xsl:text>
  847.       </xsl:when>
  848.       <xsl:otherwise>
  849.         <xsl:apply-templates/>
  850.       </xsl:otherwise>
  851.     </xsl:choose>
  852.   </tt>
  853. </xsl:template>
  854.  
  855. <xsl:template match="email">
  856.   <xsl:call-template name="inline.monoseq">
  857.     <xsl:with-param name="content">
  858.       <xsl:text><</xsl:text>
  859.       <a>
  860.        <xsl:attribute name="href">mailto:<xsl:value-of select="."/></xsl:attribute>
  861.        <xsl:apply-templates/>
  862.       </a>
  863.       <xsl:text>></xsl:text>
  864.     </xsl:with-param>
  865.   </xsl:call-template>
  866. </xsl:template>
  867.  
  868. <xsl:template match="keycombo">
  869.   <xsl:variable name="action" select="@action"/>
  870.   <xsl:variable name="joinchar">
  871.     <xsl:choose>
  872.       <xsl:when test="$action='seq'"><xsl:text> </xsl:text></xsl:when>
  873.       <xsl:when test="$action='simul'">+</xsl:when>
  874.       <xsl:when test="$action='press'">-</xsl:when>
  875.       <xsl:when test="$action='click'">-</xsl:when>
  876.       <xsl:when test="$action='double-click'">-</xsl:when>
  877.       <xsl:when test="$action='other'"></xsl:when>
  878.       <xsl:otherwise>-</xsl:otherwise>
  879.     </xsl:choose>
  880.   </xsl:variable>
  881.   <xsl:for-each select="*">
  882.     <xsl:if test="position()>1"><xsl:value-of select="$joinchar"/></xsl:if>
  883.     <xsl:apply-templates select="."/>
  884.   </xsl:for-each>
  885. </xsl:template>
  886.  
  887. <!-- ==================================================================== -->
  888.  
  889. <xsl:template match="menuchoice">
  890.   <xsl:variable name="shortcut" select="./shortcut"/>
  891.   <xsl:call-template name="process.menuchoice"/>
  892.   <xsl:if test="$shortcut">
  893.     <xsl:text> (</xsl:text>
  894.     <xsl:apply-templates select="$shortcut"/>
  895.     <xsl:text>)</xsl:text>
  896.   </xsl:if>
  897. </xsl:template>
  898.  
  899. <xsl:template name="process.menuchoice">
  900.   <xsl:param name="nodelist" select="guibutton|guiicon|guilabel|guimenu|guimenuitem|guisubmenu|interface"/><!-- not(shortcut) -->
  901.   <xsl:param name="count" select="1"/>
  902.  
  903.   <xsl:choose>
  904.     <xsl:when test="$count>count($nodelist)"></xsl:when>
  905.     <xsl:when test="$count=1">
  906.       <xsl:apply-templates select="$nodelist[$count=position()]"/>
  907.       <xsl:call-template name="process.menuchoice">
  908.         <xsl:with-param name="nodelist" select="$nodelist"/>
  909.         <xsl:with-param name="count" select="$count+1"/>
  910.       </xsl:call-template>
  911.     </xsl:when>
  912.     <xsl:otherwise>
  913.       <xsl:variable name="node" select="$nodelist[$count=position()]"/>
  914.       <xsl:choose>
  915.         <xsl:when test="name($node)='guimenuitem'
  916.                         or name($node)='guisubmenu'">
  917.           <xsl:text>-></xsl:text>
  918.         </xsl:when>
  919.         <xsl:otherwise>+</xsl:otherwise>
  920.       </xsl:choose>
  921.       <xsl:apply-templates select="$node"/>
  922.       <xsl:call-template name="process.menuchoice">
  923.         <xsl:with-param name="nodelist" select="$nodelist"/>
  924.         <xsl:with-param name="count" select="$count+1"/>
  925.       </xsl:call-template>
  926.     </xsl:otherwise>
  927.   </xsl:choose>
  928. </xsl:template>
  929.  
  930. <!-- ==================================================================== -->
  931.  
  932. <xsl:template match="optional">
  933.   <xsl:value-of select="$arg.choice.opt.open.str"/>
  934.   <xsl:call-template name="inline.charseq"/>
  935.   <xsl:value-of select="$arg.choice.opt.close.str"/>
  936. </xsl:template>
  937.  
  938. <xsl:template match="citation">
  939.   <!-- todo: biblio-citation-check -->
  940.   <xsl:text>[</xsl:text>
  941.   <xsl:call-template name="inline.charseq"/>
  942.   <xsl:text>]</xsl:text>
  943. </xsl:template>
  944.  
  945. <!-- ==================================================================== -->
  946.  
  947. <xsl:template match="comment|remark">
  948.   <xsl:if test="$show.comments != 0">
  949.     <i><xsl:call-template name="inline.charseq"/></i>
  950.   </xsl:if>
  951. </xsl:template>
  952.  
  953. <!-- ==================================================================== -->
  954.  
  955. <xsl:template match="productname">
  956.   <xsl:call-template name="inline.charseq"/>
  957.   <xsl:if test="@class">
  958.     <xsl:call-template name="dingbat">
  959.       <xsl:with-param name="dingbat" select="@class"/>
  960.     </xsl:call-template>
  961.   </xsl:if>
  962. </xsl:template>
  963.  
  964. <xsl:template match="productnumber">
  965.   <xsl:call-template name="inline.charseq"/>
  966. </xsl:template>
  967.  
  968. <!-- ==================================================================== -->
  969.  
  970. <xsl:template match="pob|street|city|state|postcode|country|otheraddr">
  971.   <xsl:call-template name="inline.charseq"/>
  972. </xsl:template>
  973.  
  974. <xsl:template match="phone|fax">
  975.   <xsl:call-template name="inline.charseq"/>
  976. </xsl:template>
  977.  
  978. <!-- in Addresses, for example -->
  979. <xsl:template match="honorific|firstname|surname|lineage|othername">
  980.   <xsl:call-template name="inline.charseq"/>
  981. </xsl:template>
  982.  
  983. <!-- ==================================================================== -->
  984.  
  985. </xsl:stylesheet>
  986.  
  987. This resource fork intentionally left blank   ˇˇ